home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: fastest code
- Date: Fri, 12 Apr 96 16:31:32 GMT
- Organization: none
- Message-ID: <829326692snz@genesis.demon.co.uk>
- References: <316112A2.7D37@public.sta.net.cn> <4kghs7$250@news1.mnsinc.com> <4kgu7g$n9a@solutions.solon.com> <yxsbukxemoi.fsf@stint.cl.cam.ac.uk> <4kljb4$nm3@solutions.solon.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4kljb4$nm3@solutions.solon.com>
- seebs@solon.com "Peter Seebach" writes:
-
- >In article <yxsbukxemoi.fsf@stint.cl.cam.ac.uk>,
- >Gareth Rees <gdr11@cl.cam.ac.uk> wrote:
- >>Surely, under the `as if' rule, code that invokes undefined behaviour
- >>*at any point* need not produce the results you expect even for those
- >>portions that don't invoke undefined behaviour?
- >
- >True, although in practice it doesn't come up.
- >
- >>So in the case
- >
- >> int x[17], i;
- >> for (i=0; i<16; i++) x[i] = x[i+i];
- >
- >>the compiler is perfectly at liberty to optimise away the loop body
- >>because of the undefined behaviour of the whole program.
-
- Yes, it is undefined by definition from ANSI/ISO 3.16 because the code uses
- the value of 'indeterminately valued objects' i.e. the elements of x
- (assuming x is defined in block scope). If x was, say, static this would be
- well defined.
-
- >Right. As it turns out, x had dimension 32 in the original post, but this
- >was not posted along with the loop description.
-
- In the test program posted recently the elements of x were suitably
- initialised.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-